<%@page import="beans.Animal"%>
<%@page import="dao.AnimalDAO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>

<%	String param[] = request.getParameter("rebanho").split("/");
    int mes = Integer.parseInt(param[0]);
    int ano = Integer.parseInt(param[1]);

	AnimalDAO animalDAO = new AnimalDAO();
	ArrayList<Animal> animais = animalDAO.loadRebanho(mes, ano);
	Iterator it = animais.iterator();
%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <%@ include file="header.html" %>
    <body>
        <%@ include file="topo.jsp" %>
        <%@ include file="menu.jsp" %>

        <div id="content">
            <h2>Registrar Morte</h2>
            <form action="doSalvarMorte.jsp" method="post">
                Rebanho: <input name="rebanho" type="text" value="<%= mes %>/<%= ano %>" readonly="readonly"><br />
                Brinco: <select name="brinco">
                    <% while (it.hasNext()) {
							Animal animal = (Animal) it.next();
                    %>
                    <option value="<%= animal.getNumBrinco() %>"><%= animal.getNumBrinco() %></option>
                    <% } %>
                </select><br />
                Motivo: <input name="motivo" type="text"><br />
                Data de morte: <input name="data" type="text"><br />
                
                <input type="submit" value="Salvar"/>
            </form>
        </div>
    </body>
</html>
